function [Output_Group] = ResBenef_Hetero_W_func(Inputs,params,Setting)

%w  = Inputs(1);
%f   = Inputs(2);
%s   = Inputs(3);
[Wage_dist, f, s]      = Inputs{:};

[tau, r, Tc,Tp]     = params{:};

b        = tau*Wage_dist;
b(b>500) = 500;
bc       = b + 600;

fr       = (1-f)/(1+r);   % discounting 
B_Tc     = b.*(1-fr^Tc)./(1-fr); % PDV of full UI spell

if Setting==1
    
    % Reservation benefits:
    br_t         = ((1+r)*Wage_dist + s*B_Tc)/(r+s+f);        % one week left
    for i = 2:Tc
        br_t(:,i)         = br_t(:,1)./((1-fr^i)/(1-fr));
    end
    
    
else
     
    
    % Reservation supplemental benefits:
    for i=1:Tp
        br_1_tc(:,i)         = ((1+r)*Wage_dist + s*B_Tc)/(r+s+f) - b.*(1-fr^(Tc-Tp+i))/(1-fr);       
    end
    
    
    br_t(:,1)         = br_1_tc(:,1)  + b;
    
    for i = 2:Tc
        if i<=Tp
            br_t(:,i)         = br_1_tc(:,i)./((1-fr^i)/(1-fr));
            br_t(:,i)         = br_t(:,i) + b;
        else
            br_1              = ((1+r)*Wage_dist + s*B_Tc)/(r+s+f);
            br_t(:,i)         = br_1./((1-fr^i)/(1-fr));
        end        
    end
    
end

[Output_Group] = {br_t; b; bc};
    